class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
        if (head == nullptr || head->next == nullptr) return head;

        ListNode* tmp = swapPairs(head->next->next);
        ListNode* next = head->next;
        head->next = tmp;
        next->next = head;
        return next;
    }
};